package com.zxx.pattern.prototypePattern.prototype;

import java.util.ArrayList;
import java.util.List;

/**
 * 原型模式
 * @author zxx on 2020/12/18
 */
public class ProtoTypeTest {

    public static void main(String[] args) {
        List<Shape> shapeList = new ArrayList<>();
        ShapeCache cache = new ShapeCache();

        shapeList.add(cache.getShape("triangle"));
        shapeList.add(cache.getShape("circle"));
        shapeList.add(cache.getShape("rectangle"));

        shapeList.add(cache.getShape("circle"));
        shapeList.add(cache.getShape("rectangle"));
        shapeList.add(cache.getShape("triangle"));

        for (Shape shape : shapeList) {
            shape.introduce();
        }
    }

}
